package com.example.eventbus.controller;

import com.example.eventbus.command.MyCommand;
import com.example.eventbus.handles.MyTestEventHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 谢汉冰
 * @Title: TestController
 * @Package com.example.eventbus.controller
 * @date 2023/10/23 15:54
 * @description:
 */

@RestController
@RequestMapping("/test")
public class TestController {

	@Autowired
	private MyTestEventHandler eventHandler;

	@GetMapping("/{id}")
	public String query(@PathVariable("id") String id) {

		eventHandler.send(new MyCommand(id));


		return "query-" + id;
	}
}
